﻿/// <reference path="references.js" />
if ( !window.Gorbatras ) window.Gorbatras = {};
if ( !window.Gorbatras.Admin ) window.Gorbatras.Admin = {};

Gorbatras.Admin.TextureSelection = {};

Gorbatras.Admin.TextureSelection.Init = function ()
{    
    Gorbatras.Admin.TextureSelection.Tooltip( "#textureSelectionDiv", "Textures" );
    Gorbatras.Admin.TextureSelection.Tooltip( "#thumbnailSelectionDiv", "Models/Thumbnails" );
};

Gorbatras.Admin.TextureSelection.Tooltip = function ( a_id, a_removePath )
{
    $( a_id ).find( ".thumbnail" ).hover( function ()
    {
        $_this = $( this );
        var f_filename = $_this.attr( "src" );
        var f_endIndex = f_filename.lastIndexOf( a_removePath + "/" );
        if ( f_filename.lastIndexOf( a_removePath + "\\" ) > f_endIndex )
        {
            f_endIndex = f_filename.lastIndexOf( a_removePath + "\\" );
        }
        
        var f_length = a_removePath.length + 1;

        f_filename = f_filename.substring( f_endIndex + f_length );
        var f_position = $_this.offset();
        //+2 px
        f_position.top += $_this.height() + 2;
        $( "body" ).append(
            $( '<div id="tooltip"><p>' + f_filename + '</p></div>' ).css( { top: f_position.top, left: f_position.left } )
        );
    },
    function ()
    {
        $( "#tooltip" ).remove();
    } );
};
